package com.jie.other.compose.study04.details

import androidx.lifecycle.ViewModel
import com.jie.other.compose.data.ExploreModel
import com.jie.other.compose.study04.Study04Repository
import kotlinx.coroutines.delay

class DetailsViewModel : ViewModel() {

    private val dataRepository = Study04Repository()

    suspend fun getDetails(cityName : String) : Result<ExploreModel>{
        delay(1000)
        val destination = dataRepository.getDestination(cityName)
        return if (destination != null) {
            Result.success(destination)
        } else {
            Result.failure(IllegalArgumentException("destination is null"))
        }
    }
}